home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
051-075
/
disk_054
/
ispell
/
access.c
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
1KB
|
50 lines
#include <stdio.h>
#include <exec/types.h> /* For Lattice 3.10, must be before exec.h! */
#include <exec/exec.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#undef TRUE
#undef FALSE
#ifdef LATTICE /* Lattice 3.10 version is hosed, use our own */
#include <error.h>
int access (path, mode)
char *path;
int mode;
{
long lck;
struct FileInfoBlock *fp;
int rtnval = 0;
register long prot;
extern long Lock ();
extern void *AllocMem ();
if ((path == 0) || ((lck = Lock (path, (long) ACCESS_READ)) == 0)) {
rtnval = -1;
errno = ENOENT;
} else {
fp = (struct FileInfoBlock *)
AllocMem ((long) sizeof (struct FileInfoBlock),
(long) (MEMF_CLEAR | MEMF_CHIP));
if (Examine (lck, fp) == 0) {
rtnval = -1;
errno = EACCES;
} else {
prot = fp -> fib_Protection;
if ( ((mode & 1) && (prot & FIBF_EXECUTE))
|| ((mode & 2) && (prot & FIBF_WRITE))
|| ((mode & 4) && (prot & FIBF_READ))) {
rtnval = -1;
errno = EACCES;
}
}
FreeMem (fp, (long) sizeof (struct FileInfoBlock));
UnLock (lck);
}
return (rtnval);
}
#endif